package main

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/logs"
	_ "go-cms/routers" // 路由
	_ "go-cms/sysinit" // 初始化系统配置
)

// 视频：https://www.imooc.com/video/20265
// 文档：https://ziyoubiancheng.com/xcms/
func main() {
	defer coverPainc() // 捕获异常
	logs.SetLevel(beego.LevelInformational)
	logs.SetLogger("file", `{"filename":"logs/test.log"}`) //输出日志到文件 /logs/test.log

	beego.Run() // 启动框架
}

func coverPainc() {
	message := recover()
	switch message.(type) {
	case string:
		beego.Error("",message)
	case error:
		beego.Error("",message)
	default:
		beego.Error("unknown panic : ",message)
	}
}
